package com.frame.auth.resource.security.handler;

import com.frame.common.core.util.ResponseUtils;
import com.frame.common.tools.result.ServiceResult;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 身份验证成功
 *
 * @auther zhangwj
 * @date 2021/3/18 下午1:47
 */
public class GoAuthenticationSuccessHandler implements AuthenticationSuccessHandler {

    @Override
    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest,
                                        HttpServletResponse httpServletResponse,
                                        Authentication authentication) throws IOException, ServletException {
        Map<String, String> map = new HashMap<>(4);
        map.put("access_token", "");
        map.put("expires_in", "");
        map.put("refresh_token", "");
        map.put("re_expires_in", "");
        ResponseUtils.writeJson(httpServletResponse, ServiceResult.getSuccessResult(map));
    }
}
